"""modify time attr

Revision ID: 72d242903d39
Revises: 3d275811bda5
Create Date: 2025-04-25 00:52:50.463321

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = '72d242903d39'
down_revision: Union[str, None] = '3d275811bda5'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('ai_agents', 'system_prompt',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_comment='系统提示词',
               existing_nullable=True)
    op.alter_column('ai_agents', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_agents', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_agents-group', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_agents-group', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_api', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_api', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_config', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_config', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_model', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_model', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('api_keys', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('api_keys', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('chats', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('chats', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('documents', 'created_at',
               existing_type=mysql.DATETIME(),
               type_=sa.TIMESTAMP(),
               nullable=False,
               existing_comment='创建时间',
               existing_server_default=sa.text('CURRENT_TIMESTAMP'))
    op.alter_column('documents', 'updated_at',
               existing_type=mysql.DATETIME(),
               nullable=False,
               existing_comment='更新时间')
    op.alter_column('funcall_log', 'log_text',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_comment='日志信息',
               existing_nullable=True)
    op.alter_column('funcall_log', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('funcall_log', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('knowledge_bases', 'created_at',
               existing_type=mysql.DATETIME(),
               type_=sa.TIMESTAMP(),
               nullable=False,
               comment='创建时间')
    op.alter_column('knowledge_bases', 'updated_at',
               existing_type=mysql.DATETIME(),
               nullable=False,
               comment='更新时间')
    op.alter_column('messages', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('messages', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('openai_log', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('openai_log', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('tools', 'tool_desc',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_nullable=True)
    op.alter_column('tools', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('tools', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    op.alter_column('users', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment='创建时间',
               existing_nullable=False)
    op.alter_column('users', 'updated_at',
               existing_type=mysql.TIMESTAMP(),
               type_=sa.DateTime(),
               comment='更新时间',
               existing_nullable=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('users', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('users', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('tools', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('tools', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('tools', 'tool_desc',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_nullable=True)
    op.alter_column('openai_log', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('openai_log', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('messages', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('messages', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('knowledge_bases', 'updated_at',
               existing_type=mysql.DATETIME(),
               nullable=True,
               comment=None,
               existing_comment='更新时间')
    op.alter_column('knowledge_bases', 'created_at',
               existing_type=sa.TIMESTAMP(),
               type_=mysql.DATETIME(),
               nullable=True,
               comment=None,
               existing_comment='创建时间')
    op.alter_column('funcall_log', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('funcall_log', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('funcall_log', 'log_text',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_comment='日志信息',
               existing_nullable=True)
    op.alter_column('documents', 'updated_at',
               existing_type=mysql.DATETIME(),
               nullable=True,
               existing_comment='更新时间')
    op.alter_column('documents', 'created_at',
               existing_type=sa.TIMESTAMP(),
               type_=mysql.DATETIME(),
               nullable=True,
               existing_comment='创建时间',
               existing_server_default=sa.text('CURRENT_TIMESTAMP'))
    op.alter_column('chats', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('chats', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('api_keys', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('api_keys', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_model', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_model', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_config', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_config', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_api', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_api', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_agents-group', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_agents-group', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_agents', 'updated_at',
               existing_type=sa.DateTime(),
               type_=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('ai_agents', 'created_at',
               existing_type=mysql.TIMESTAMP(),
               comment=None,
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('ai_agents', 'system_prompt',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_comment='系统提示词',
               existing_nullable=True)
    # ### end Alembic commands ###
